//
//  HomeOptimizationCell.m
//  GSBlockChain
//
//  Created by guoshikeji_a on 2018/11/20.
//  Copyright © 2018年 guoshikeji. All rights reserved.
//

#import "HomeOptimizationCell.h"

//显示
#import "CustomProjectContentView.h"

static CGFloat HomeOptimizationCellContentHeight = 185.0;
static CGFloat HomeOptimizationCellBottomPadding = 15.0;

@interface HomeOptimizationCell ()

@property (nonatomic, strong) CustomProjectContentView *customContentView;

@end

@implementation HomeOptimizationCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        //
        self.customContentView = [CustomProjectContentView new];
        [self.contentView addSubview:self.customContentView];
        [self.customContentView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.contentView);
            make.centerX.mas_equalTo(self.contentView);
            make.width.mas_equalTo(self.contentView).offset(-20.0);
            make.height.mas_equalTo(HomeOptimizationCellContentHeight);
        }];
        self.customContentView.backgroundColor = [UIColor whiteColor];
        self.customContentView.layer.cornerRadius = 4;
        self.customContentView.layer.shadowOpacity = 1;
        self.customContentView.layer.shadowColor = RGBHEXA(0x000000, 0.12).CGColor;
        self.customContentView.layer.shadowOffset = CGSizeMake(0, 1);
        self.customContentView.layer.shadowRadius = 8;
        //
        
        UITapGestureRecognizer *tapCollection = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapCollectionAction)];
        [self.customContentView.displayCollection addGestureRecognizer:tapCollection];
    }
    return self;
}
#pragma mark - tapCollectionAction
- (void)tapCollectionAction {
    if (self.tableView) {
        if (self.tableView.delegate && [self.tableView.delegate respondsToSelector:@selector(tableView:didSelectRowAtIndexPath:)]) {
            [self.tableView.delegate tableView:self.tableView didSelectRowAtIndexPath:[self.tableView indexPathForCell:self]];
        }
    }
}


- (void)setCellData:(BCProjectModel *)cellData {
    _cellData = cellData;
    self.customContentView.contentData = cellData;
}



- (void)layoutSubviews {
    [super layoutSubviews];
}





+ (CGFloat)defaultHeight {
    return HomeOptimizationCellContentHeight+HomeOptimizationCellBottomPadding;
}

@end
